Clarify behavior in docs, #61777 (gtk_text_iter_forward_search)
authorHavoc Pennington <hp@redhat.com>
Mon, 22 Oct 2001 19:13:28 +0000 (19:13 +0000)
committerHavoc Pennington <hp@src.gnome.org>
Mon, 22 Oct 2001 19:13:28 +0000 (19:13 +0000)
2001-10-22  Havoc Pennington  <hp@redhat.com>

* gtk/gtktextiter.c (gtk_text_iter_set_line): Clarify behavior in
docs, #61777
(gtk_text_iter_forward_search) (gtk_text_iter_backward_search):
change the two boolean args to a flags field, so we can extend
to add case insensitive, regexp searches later. #61852

12 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
docs/reference/gtk/tmpl/gtkmenu.sgml
docs/reference/gtk/tmpl/gtktextiter.sgml
gtk/gtktextiter.c
gtk/gtktextiter.h
tests/testtext.c

index 4ad4aaae81b76ea4308325c7940df260f6f43f47..aed7aa0fbad450603a4e0d20053573e2c30addd1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2001-10-22  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextiter.c (gtk_text_iter_set_line): Clarify behavior in
+       docs, #61777
+       (gtk_text_iter_forward_search) (gtk_text_iter_backward_search):
+       change the two boolean args to a flags field, so we can extend 
+       to add case insensitive, regexp searches later. #61852
+
 Mon Oct 22 15:07:17 2001  Jonathan Blandford  <jrb@redhat.com>
 
        * gtk/gtktreestore.c (gtk_tree_store_iter_depth): update docs to
index 4ad4aaae81b76ea4308325c7940df260f6f43f47..aed7aa0fbad450603a4e0d20053573e2c30addd1 100644 (file)
@@ -1,3 +1,11 @@
+2001-10-22  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextiter.c (gtk_text_iter_set_line): Clarify behavior in
+       docs, #61777
+       (gtk_text_iter_forward_search) (gtk_text_iter_backward_search):
+       change the two boolean args to a flags field, so we can extend 
+       to add case insensitive, regexp searches later. #61852
+
 Mon Oct 22 15:07:17 2001  Jonathan Blandford  <jrb@redhat.com>
 
        * gtk/gtktreestore.c (gtk_tree_store_iter_depth): update docs to
index 4ad4aaae81b76ea4308325c7940df260f6f43f47..aed7aa0fbad450603a4e0d20053573e2c30addd1 100644 (file)
@@ -1,3 +1,11 @@
+2001-10-22  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextiter.c (gtk_text_iter_set_line): Clarify behavior in
+       docs, #61777
+       (gtk_text_iter_forward_search) (gtk_text_iter_backward_search):
+       change the two boolean args to a flags field, so we can extend 
+       to add case insensitive, regexp searches later. #61852
+
 Mon Oct 22 15:07:17 2001  Jonathan Blandford  <jrb@redhat.com>
 
        * gtk/gtktreestore.c (gtk_tree_store_iter_depth): update docs to
index 4ad4aaae81b76ea4308325c7940df260f6f43f47..aed7aa0fbad450603a4e0d20053573e2c30addd1 100644 (file)
@@ -1,3 +1,11 @@
+2001-10-22  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextiter.c (gtk_text_iter_set_line): Clarify behavior in
+       docs, #61777
+       (gtk_text_iter_forward_search) (gtk_text_iter_backward_search):
+       change the two boolean args to a flags field, so we can extend 
+       to add case insensitive, regexp searches later. #61852
+
 Mon Oct 22 15:07:17 2001  Jonathan Blandford  <jrb@redhat.com>
 
        * gtk/gtktreestore.c (gtk_tree_store_iter_depth): update docs to
index 4ad4aaae81b76ea4308325c7940df260f6f43f47..aed7aa0fbad450603a4e0d20053573e2c30addd1 100644 (file)
@@ -1,3 +1,11 @@
+2001-10-22  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextiter.c (gtk_text_iter_set_line): Clarify behavior in
+       docs, #61777
+       (gtk_text_iter_forward_search) (gtk_text_iter_backward_search):
+       change the two boolean args to a flags field, so we can extend 
+       to add case insensitive, regexp searches later. #61852
+
 Mon Oct 22 15:07:17 2001  Jonathan Blandford  <jrb@redhat.com>
 
        * gtk/gtktreestore.c (gtk_tree_store_iter_depth): update docs to
index 4ad4aaae81b76ea4308325c7940df260f6f43f47..aed7aa0fbad450603a4e0d20053573e2c30addd1 100644 (file)
@@ -1,3 +1,11 @@
+2001-10-22  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextiter.c (gtk_text_iter_set_line): Clarify behavior in
+       docs, #61777
+       (gtk_text_iter_forward_search) (gtk_text_iter_backward_search):
+       change the two boolean args to a flags field, so we can extend 
+       to add case insensitive, regexp searches later. #61852
+
 Mon Oct 22 15:07:17 2001  Jonathan Blandford  <jrb@redhat.com>
 
        * gtk/gtktreestore.c (gtk_tree_store_iter_depth): update docs to
index 4ad4aaae81b76ea4308325c7940df260f6f43f47..aed7aa0fbad450603a4e0d20053573e2c30addd1 100644 (file)
@@ -1,3 +1,11 @@
+2001-10-22  Havoc Pennington  <hp@redhat.com>
+
+       * gtk/gtktextiter.c (gtk_text_iter_set_line): Clarify behavior in
+       docs, #61777
+       (gtk_text_iter_forward_search) (gtk_text_iter_backward_search):
+       change the two boolean args to a flags field, so we can extend 
+       to add case insensitive, regexp searches later. #61852
+
 Mon Oct 22 15:07:17 2001  Jonathan Blandford  <jrb@redhat.com>
 
        * gtk/gtktreestore.c (gtk_tree_store_iter_depth): update docs to
index b8f6c879354f39e68fa2b852deeb6fbb9f7d7dc5..b51c366a4b8e9cfdb935d43b88694d40851c99fa 100644 (file)
@@ -96,9 +96,9 @@ Creates a new #GtkMenu.
 Adds a new #GtkMenuItem to the end of the menu's item list.
 </para>
 
+<!-- # Unused Parameters # -->
 @menu: a #GtkMenu.
 @child: The #GtkMenuItem to add.
-<!-- # Unused Parameters # -->
 @m: 
 @c: 
 
@@ -108,9 +108,9 @@ Adds a new #GtkMenuItem to the end of the menu's item list.
 Adds a new #GtkMenuItem to the beginning of the menu's item list.
 </para>
 
+<!-- # Unused Parameters # -->
 @menu: a #GtkMenu.
 @child: The #GtkMenuItem to add.
-<!-- # Unused Parameters # -->
 @menu_child: 
 @m: 
 @c: 
@@ -122,10 +122,10 @@ Adds a new #GtkMenuItem to the menu's item list at the position
 indicated by @position. 
 </para>
 
+<!-- # Unused Parameters # -->
 @menu: a #GtkMenu.
 @child: The #GtkMenuItem to add.
 @pos: 
-<!-- # Unused Parameters # -->
 @position: The position in the item list where @child is added.
 Positions are numbered from 0 to n-1.
 
index aae67a4ddf01e50520566c735d55ef5f995548d2..1815bd9654b63e913a6120de3212c5ed6e6c8aa0 100644 (file)
@@ -715,12 +715,14 @@ types related to the text widget and how they work together.
 
 @iter: 
 @str: 
-@visible_only: 
-@slice: 
+@flags: 
 @match_start: 
 @match_end: 
 @limit: 
 @Returns: 
+<!-- # Unused Parameters # -->
+@visible_only: 
+@slice: 
 
 
 <!-- ##### FUNCTION gtk_text_iter_backward_search ##### -->
@@ -730,12 +732,14 @@ types related to the text widget and how they work together.
 
 @iter: 
 @str: 
-@visible_only: 
-@slice: 
+@flags: 
 @match_start: 
 @match_end: 
 @limit: 
 @Returns: 
+<!-- # Unused Parameters # -->
+@visible_only: 
+@slice: 
 
 
 <!-- ##### FUNCTION gtk_text_iter_equal ##### -->
index 1b8fbf9317797677d18a015372ec9f40f70c9e2e..ab387f4cd144a01173e9811310f0df26431f1497 100644 (file)
@@ -3632,7 +3632,9 @@ gtk_text_iter_set_visible_line_index  (GtkTextIter *iter,
  * @iter: a #GtkTextIter
  * @line_number: line number (counted from 0)
  *
- * Moves iterator @iter to the start of the line @line_number.
+ * Moves iterator @iter to the start of the line @line_number.  If
+ * @line_number is negative or larger than the number of lines in the
+ * buffer, moves @iter to the start of the last line in the buffer.
  * 
  **/
 void
@@ -4243,23 +4245,31 @@ strbreakup (const char *string,
  * gtk_text_iter_forward_search:
  * @iter: start of search
  * @str: a search string
- * @visible_only: if %TRUE, search only visible text
- * @slice: if %TRUE, @str contains 0xFFFC when we want to match widgets, pixbufs
+ * @flags: flags affecting how the search is done
  * @match_start: return location for start of match, or %NULL
  * @match_end: return location for end of match, or %NULL
  * @limit: bound for the search, or %NULL for the end of the buffer
  * 
- * Searches forward for @str. Any match is returned as the range @match_start,
- * @match_end. If you specify @visible_only or @slice, the match may have
- * invisible text, pixbufs, or child widgets interspersed in @str.
+ * Searches forward for @str. Any match is returned as the range
+ * @match_start, @match_end. The search will not continue past
+ * @limit. Note that a search is a linear or O(n) operation, so you
+ * may wish to use @limit to avoid locking up your UI on large
+ * buffers.
  * 
+ * If the #GTK_TEXT_SEARCH_VISIBLE_ONLY flag is present, the match may
+ * have invisible text interspersed in @str. i.e. @str will be a
+ * possibly-noncontiguous subsequence of the matched range. similarly,
+ * if you specify #GTK_TEXT_SEARCH_TEXT_ONLY, the match may have
+ * pixbufs or child widgets mixed inside the matched range. If these
+ * flags are not given, the match must be exact; the special 0xFFFC
+ * character in @str will match embedded pixbufs or child widgets.
+ *
  * Return value: whether a match was found
  **/
 gboolean
 gtk_text_iter_forward_search (const GtkTextIter *iter,
                               const gchar       *str,
-                              gboolean           visible_only,
-                              gboolean           slice,
+                              GtkTextSearchFlags flags,
                               GtkTextIter       *match_start,
                               GtkTextIter       *match_end,
                               const GtkTextIter *limit)
@@ -4268,7 +4278,9 @@ gtk_text_iter_forward_search (const GtkTextIter *iter,
   GtkTextIter match;
   gboolean retval = FALSE;
   GtkTextIter search;
-
+  gboolean visible_only;
+  gboolean slice;
+  
   g_return_val_if_fail (iter != NULL, FALSE);
   g_return_val_if_fail (str != NULL, FALSE);
 
@@ -4297,6 +4309,9 @@ gtk_text_iter_forward_search (const GtkTextIter *iter,
         return FALSE;
     }
 
+  visible_only = (flags & GTK_TEXT_SEARCH_VISIBLE_ONLY) != 0;
+  slice = (flags & GTK_TEXT_SEARCH_TEXT_ONLY) == 0;
+  
   /* locate all lines */
 
   lines = strbreakup (str, "\n", -1);
@@ -4563,8 +4578,7 @@ my_strrstr (const gchar *haystack,
  * gtk_text_iter_backward_search:
  * @iter: a #GtkTextIter where the search begins
  * @str: search string
- * @visible_only: if %TRUE search only visible text
- * @slice: if %TRUE the search string contains 0xFFFC to match pixbufs, widgets
+ * @flags: bitmask of flags affecting the search
  * @match_start: return location for start of match, or %NULL
  * @match_end: return location for end of match, or %NULL
  * @limit: location of last possible @match_start, or %NULL for start of buffer
@@ -4576,8 +4590,7 @@ my_strrstr (const gchar *haystack,
 gboolean
 gtk_text_iter_backward_search (const GtkTextIter *iter,
                                const gchar       *str,
-                               gboolean           visible_only,
-                               gboolean           slice,
+                               GtkTextSearchFlags flags,
                                GtkTextIter       *match_start,
                                GtkTextIter       *match_end,
                                const GtkTextIter *limit)
@@ -4587,7 +4600,9 @@ gtk_text_iter_backward_search (const GtkTextIter *iter,
   gint n_lines;
   LinesWindow win;
   gboolean retval = FALSE;
-
+  gboolean visible_only;
+  gboolean slice;
+  
   g_return_val_if_fail (iter != NULL, FALSE);
   g_return_val_if_fail (str != NULL, FALSE);
 
@@ -4615,6 +4630,9 @@ gtk_text_iter_backward_search (const GtkTextIter *iter,
         return FALSE;
     }
 
+  visible_only = (flags & GTK_TEXT_SEARCH_VISIBLE_ONLY) != 0;
+  slice = (flags & GTK_TEXT_SEARCH_TEXT_ONLY) == 0;
+  
   /* locate all lines */
 
   lines = strbreakup (str, "\n", -1);
index 8d6096ca9cec89f3b3e5ab8274712d5abd97ae3a..887593f01f5d9f766620d02b863f6eaafb95ddd5 100644 (file)
 extern "C" {
 #endif /* __cplusplus */
 
+typedef enum {
+  GTK_TEXT_SEARCH_VISIBLE_ONLY,
+  GTK_TEXT_SEARCH_TEXT_ONLY
+  /* Possible future plans: SEARCH_CASE_INSENSITIVE, SEARCH_REGEXP */
+} GtkTextSearchFlags;
+
 /*
  * Iter: represents a location in the text. Becomes invalid if the
  * characters/pixmaps/widgets (indexable objects) in the text buffer
@@ -236,16 +242,14 @@ gboolean gtk_text_iter_backward_find_char (GtkTextIter          *iter,
 
 gboolean gtk_text_iter_forward_search  (const GtkTextIter *iter,
                                         const gchar       *str,
-                                        gboolean           visible_only,
-                                        gboolean           slice,
+                                        GtkTextSearchFlags flags,
                                         GtkTextIter       *match_start,
                                         GtkTextIter       *match_end,
                                         const GtkTextIter *limit);
 
 gboolean gtk_text_iter_backward_search (const GtkTextIter *iter,
                                         const gchar       *str,
-                                        gboolean           visible_only,
-                                        gboolean           slice,
+                                        GtkTextSearchFlags flags,
                                         GtkTextIter       *match_start,
                                         GtkTextIter       *match_end,
                                         const GtkTextIter *limit);
index 09ef2ace26c9593c28e0e44e37c70e9f1371dff5..707c8eb04d0267614c799f5aa91a6b7490242c96 100644 (file)
@@ -1578,7 +1578,9 @@ buffer_search (Buffer     *buffer,
 
       if (forward)
         {
-          while (gtk_text_iter_forward_search (&iter, str, TRUE, FALSE,
+          while (gtk_text_iter_forward_search (&iter, str,
+                                               GTK_TEXT_SEARCH_VISIBLE_ONLY |
+                                               GTK_TEXT_SEARCH_TEXT_ONLY,
                                                &match_start, &match_end,
                                                NULL))
             {
@@ -1591,7 +1593,9 @@ buffer_search (Buffer     *buffer,
         }
       else
         {
-          while (gtk_text_iter_backward_search (&iter, str, TRUE, FALSE,
+          while (gtk_text_iter_backward_search (&iter, str,
+                                                GTK_TEXT_SEARCH_VISIBLE_ONLY |
+                                                GTK_TEXT_SEARCH_TEXT_ONLY,
                                                 &match_start, &match_end,
                                                 NULL))
             {